import { _decorator, Component, Label, Node, tween, v3 } from "cc";
import { back } from "./back";
const { ccclass, property } = _decorator;

@ccclass("j3")
export class j3 extends back {
  @property(Node)
  item1: Node = null;
  @property(Node)
  item2: Node = null;
  @property(Node)
  item3: Node = null;
  @property(Label)
  label: Label = null;
  start() {
    tween(this.item2)
      .by(1, { position: v3(300, 0, 0) })
      .call(() => {
        // item1 跑到最前面
        this.item1.setSiblingIndex(0);
        this.item2.setSiblingIndex(2);
        this.item3.setSiblingIndex(1);
        this.label.string = "在最前面";
      })
      .by(1, { position: v3(-300, 0, 0) })
      .by(1, { position: v3(300, 0, 0) })
      .by(1, { position: v3(-300, 0, 0) })
      .call(() => {
        // cocos2 跑到最后面
        this.item1.setSiblingIndex(1);
        this.item2.setSiblingIndex(0);
        this.item3.setSiblingIndex(2);
        this.label.string = "在最后面";
      })
      .by(1, { position: v3(300, 0, 0) })
      .by(1, { position: v3(-300, 0, 0) })
      .union()
      .repeatForever()
      .start();
  }

  update(deltaTime: number) {}
}
